import Vue from 'vue';
import App from './App.vue';
import router from './router';
import $ from 'jquery';
import 'element-ui/lib/theme-chalk/index.css';

import ElementUI from 'element-ui';
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';

Vue.use(ElementUI);
import {
  Form,
  Button,
  Select,
  Table,
  Input,
  Pagination,
  Autocomplete,
  Upload,
  DatePicker,
  Option,
  Checkbox,
  CheckboxButton,
  CheckboxGroup,
  TableColumn,
  Tree
} from 'element-ui';

Vue.use(Form);
Vue.use(Button);
Vue.use(TableColumn);
Vue.use(Option);
// Vue.use(Upload);
Vue.use(DatePicker);
// Vue.use(Pagination);
Vue.use(Autocomplete);
Vue.use(Input);
Vue.use(Select);
Vue.use(Checkbox);
Vue.use(CheckboxButton);
// Vue.use(CheckboxGroup)
Vue.use(Table);
// Vue.use(Tree);

import VueQuillEditor from 'vue-quill-editor';

Vue.use(VueQuillEditor);
//
//
import './assets/css/bootstrap.min.css';
import './assets/css/common.css';
import './assets/js/zTreeStyle.css';
import './assets/fonts/iconfont.css';
//wangEditor富文本编辑器css样式
import '@wangeditor/editor/dist/css/style.css';

import qs from 'qs';
Vue.prototype.$qs = qs;

import * as dd from 'dingtalk-jsapi';
import md5 from 'js-md5';
Vue.prototype.$md5 = md5;

// Vue.prototype.$url = 'https://xcx.ycylyy.com:83/gd'
Vue.prototype.$url = 'http://43.137.15.216:81/gd';
// Vue.prototype.$url = 'http://www.ytitsm.com/gd'
// Vue.prototype.$url = sessionStorage.getItem('url')

// import "@/components/browser.js";
Vue.prototype.$permissions = sessionStorage.getItem('permissions')
  ? sessionStorage.getItem('permissions')
  : [];
Vue.prototype.$realName = sessionStorage.getItem('realName')
  ? sessionStorage.getItem('realName')
  : '';

import { NewToast } from '@/components/index.js';
Vue.use(NewToast);

import * as echarts from 'echarts/core';
// 引入柱状图图表，图表后缀都为 Chart
import { BarChart } from 'echarts/charts';
import { LineChart } from 'echarts/charts';
import { PieChart } from 'echarts/charts';
// 引入提示框，标题，直角坐标系，数据集，内置数据转换器组件，组件后缀都为 Component
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  PolarComponent
} from 'echarts/components';
// 标签自动布局，全局过渡动画等特性
import { LabelLayout, UniversalTransition } from 'echarts/features';
// 引入 Canvas 渲染器，注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
import { CanvasRenderer } from 'echarts/renderers';

// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  BarChart,
  LineChart,
  PieChart,
  LabelLayout,
  UniversalTransition,
  CanvasRenderer,
  PolarComponent
]);

Vue.prototype.$echarts = echarts;

import axios from 'axios';
// axios.defaults.headers["X-Content-Type-Options"] = "nosniff";
// axios.defaults.headers["X-Content-Type-Options"] = "nosniff";
// axios.defaults.headers["X-Download-Options"] = "noopen";
// axios.defaults.headers["X-Frame-Options"] = "DENY";
// axios.defaults.headers["X-Permitted-Cross-Domain-Policies"] = "master-only";
// axios.defaults.headers["X-XSS-Protection"] = "1; mode=block";
// axios.defaults.headers["Strict-Transport-Security"] = "max-age=31536000 ; includeSubDomains";

axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded';

axios.defaults.headers['Authorization'] = sessionStorage.getItem('token');
Vue.prototype.$http = axios;

import storage from './utils/storage';
Vue.prototype.$storage = storage;

import 'ztree';

const requireComponent = require.context(
  './components', // 组件文件夹的相对路径
  true, // 是否递归查找子文件夹
  /\.vue$/ // 组件文件的匹配规则
);

requireComponent.keys().forEach((fileName) => {
  const componentConfig = requireComponent(fileName);

  const componentName = fileName
    .split('/')
    .pop()
    .replace(/\.\w+$/, '');

  Vue.component(componentName, componentConfig.default || componentConfig);
});
import XLSX from 'xlsx-style';

Vue.config.productionTip = false;

Vue.prototype.resetSetItem = function (key, newVal) {
  if (key === 'rou') {
    // 创建一个StorageEvent事件
    var newStorageEvent = document.createEvent('StorageEvent');
    const storage = {
      setItem: function (k, val) {
        sessionStorage.setItem(k, val);

        // 初始化创建的事件
        newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null);

        // 派发对象
        window.dispatchEvent(newStorageEvent);
      }
    };
    return storage.setItem(key, newVal);
  }
};

new Vue({
  router,
  // store,
  render: (h) => h(App)
}).$mount('#app');
